#include <bits/stdc++.h>
using namespace std;
long long int cnt;
int price[105];
struct Student{
    string name;
    int avg_score;
    int py_score;
    bool is_monitor;
    bool is_west;
    int paper;
    int price;
}stu[105];
void calc(Student s,int i){
    price[i]=0;
    if (s.avg_score>80 && s.paper >=1){
        price[i]+=8000;
        cnt+=8000;
    }
    if (s.avg_score>85 && s.py_score > 80)
    {
        price[i]+=4000;
        cnt+=4000;
    } 
    if (s.avg_score>90) {
        price[i]+=2000;
        cnt+=2000;
    }

    if (s.avg_score > 85 && s.is_west)
    {
        price[i]+=1000;
        cnt+=1000;
    }
    if (s.py_score>80 && s.is_monitor)
    {
        price[i]+=850;
        cnt+=850;
    }
}
int main(){
    int n;
    cin>>n;
    char flag;
    for (int i=0;i<n;i++){
        cin>>stu[i].name
            >>stu[i].avg_score
            >>stu[i].py_score;
        cin>>flag;
        if (flag=='Y')
        {
            stu[i].is_monitor=1;
        }
        else if (flag=='N')
        {
            stu[i].is_monitor=0;
        }
        cin>>flag;
        if (flag=='Y')
        {
            stu[i].is_west=1;
        }
        else if (flag=='N')
        {
            stu[i].is_west=0;
        }
        cin>>stu[i].paper;
        calc(stu[i],i);
    }
    int index=0;
    int mx=0;
    for (int i=0; i < n; i++)
    {
        if (price[i] > mx) {
            mx = price[i];
            index = i;
        }
    }
    cout<<stu[index].name<<endl
        <<price[index]<<endl
        <<cnt;
    return 0;
}